import axios from 'axios' //引入axios
import user from '../modules/user'

const axiosServer=function (url,data,successBack,config={method:'post'},errorBack){

  axios({
      method:config.method,
      url:url,
      data:data,
	  params:data,
	  headers:{'authorization': user.state.token},
    }).then((response) =>{
    if(response.data.status!=0){
      // Vue.$vux.toast.text(response.data.message)
    }
    successBack(response)
  }).catch( error =>{
    if(error.response){
      if(error.response.data.status!=0){
        
      }
    }
    if(typeof(errorBack) == 'function'){
      errorBack(error);
    }
  });
}

export default axiosServer